package uppacket

import (
	"gitee.com/yanwc/ebicycle/device/frame"

	"github.com/panjf2000/gnet"
)

type IPacket interface {
	// 内部实现需要使用goroutine 执行
	Do(f frame.IFrame, c gnet.Conn) ([]byte, gnet.Action, error)
}

const (
	WildCommandWord      byte = 0x00 // 服务器透传命令字
	HeartBeatCommandWord byte = 0x02 // 心跳
	WarnCommandWord      byte = 0x05 // 告警
	LoginCommandWord     byte = 0x23 // 登录
	StatusCommandWord    byte = 0x51 // 状态上报
)

var Packets = map[byte]IPacket{
	WildCommandWord:      &WildPacket{},
	HeartBeatCommandWord: &HeartBeatPacket{},
	WarnCommandWord:      &WarnPacket{},
	LoginCommandWord:     &LoginPacket{},
	StatusCommandWord:    &StatusPacket{},
}
